/*
 * Student.cpp
 */

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include "Student.h"

//Constructor with default input arguments
//Student::Student(int ssn = 0, string lastname = "McFake", string firstname = "Fakity", string address = "42 Wallaby Place", int major = 1) :
Student::Student(int ssn, string lastname, string firstname, string address, int major) :
	_SSN(ssn),
	_major(major)
{
	int length=lastname.copy(_last_name, min((int)lastname.size(), 31), 0); //hardcode char-array length - 1
	_last_name[length]='\0';
	length=firstname.copy(_first_name, min((int)firstname.size(), 15), 0); //hardcode char-array length - 1
	_first_name[length]='\0';
	length=address.copy(_address, min((int)address.size(), 63), 0); //hardcode char-array length - 1
	_address[length]='\0';
}

//Copy constructor
Student::Student(Student &copy) :
	_SSN(copy._SSN),
	_major(copy._major)
{
	strcpy(_last_name, copy._last_name);
	strcpy(_first_name, copy._first_name);
	strcpy(_address, copy._address);
}

Student::~Student() {
}

//Output student information to console
void Student::Print() {
	cout << "Student: " << GetStudentString() << endl;
}

//Return student information in a string
string Student::GetStudentString() {
	ostringstream builtString;
	builtString << _SSN << ", " << GetName() << ", " << _address << ", " << _major << " major";
	return builtString.str();
}

//Return student SSN
int Student::GetSsn() {
	return _SSN;
}

//Return formatted student name
string Student::GetName() {
	ostringstream builtString;
	builtString << _last_name << ", " << _first_name;
	return builtString.str();
}
